﻿using BarManager.Core.Entity;
using System.Data.Entity.ModelConfiguration;

namespace BarManager.Infrastructure.Data.Mapping
{
    public class OrdenMap : EntityTypeConfiguration<Orden>
    {
        public OrdenMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Table & Column Mappings
            this.ToTable("Orden");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.FechaCreacion).HasColumnName("FechaCreacion");
            this.Property(t => t.FechaCierre).HasColumnName("FechaCierre");
            this.Property(t => t.Estado).HasColumnName("Estado");
            this.Property(t => t.MesaId).HasColumnName("MesaId");
            this.Property(t => t.EmpleadoId).HasColumnName("EmpleadoId");

            // Relationships
            this.HasRequired(t => t.Empleado)
                .WithMany(t => t.OrdenList)
                .HasForeignKey(d => d.EmpleadoId);
            this.HasRequired(t => t.Mesa)
                .WithMany(t => t.OrdenList)
                .HasForeignKey(d => d.MesaId);
        }
    }
}
